package com.project.yuepai.config;

import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 *  描述：自定义错误页面
 *  @Author: Lai
 *  @date: 2021年10月20日15:32:17
 */
@Configuration
public class ErrorPageConfig {
    @Bean
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory>
        webServerFactoryCustomizer(){
        return ( container-> {
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND,"/404.html");
            container.addErrorPages(error404Page);
        });
    }
}
